﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace Web.Controllers
{
    public class ChangeController : Controller
    {
        //
        // GET: /Change/
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public ActionResult DocType1()
        {
            //Session["doctype"] = 1;

            var ticket = Common.GetTicket();
            FormsAuthenticationTicket ticketnew = new FormsAuthenticationTicket(
                1, // 版本
                ticket.Name,
                DateTime.Now, // 票据的签发时间
                DateTime.Now.AddHours(1), // 票据的过期时间
                false, // 是否为永久Cookie
                "1" // 附加的用户数据，此处用来存放用户角色
               );

            string encryptedTicket = FormsAuthentication.Encrypt(ticketnew);
            var cookie = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName];
            cookie.Value = encryptedTicket;
            HttpContext.Response.Cookies.Add(cookie);
            return RedirectToAction("index", "index");
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public ActionResult DocType2()
        {
            //Session["doctype"] = 2;
            var ticket = Common.GetTicket();
            FormsAuthenticationTicket ticketnew = new FormsAuthenticationTicket(
                1, // 版本
               ticket.Name,
                DateTime.Now, // 票据的签发时间
                DateTime.Now.AddHours(1), // 票据的过期时间
                false, // 是否为永久Cookie
                "2" // 附加的用户数据，此处用来存放用户角色
               );

            string encryptedTicket = FormsAuthentication.Encrypt(ticketnew);
            var cookie = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName];
            cookie.Value = encryptedTicket;
            HttpContext.Response.Cookies.Add(cookie);
            return RedirectToAction("index", "index");
        }
    }
}
